<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/validate.jsp"%>
<%@ include file="/common/verfy.jsp"%>
<%@ include file="/common/szws.jsp"%>
<%
    Integer id = input.getInt("id", -1);
	String type = input.getDesc("type", "expert");
	if ("1".equals(checkSource(application.getRealPath("/") + appType + "/" + hospital + "/conf.xml")) && "normal".equals(type)) {  // 1代表实时号
		List<Dept> depts = QBuilder.db("basedb").select().from("Dept").where(new Where("hospital =", hospital).and("status = ", STATUS_ENABLE).and("id=", id)).query().getResultObj();
		if (depts.size() == 0) {
			msg = new Message(30041, "获取号源失败");
			Tools.encryptPrint(out, msg);
			return;
		}
		Dept dept = depts.get(0);
		String hospitalName = "1".equals(dept.getBranch()+"") ? "苏州市立医院本部" : "2".equals(dept.getBranch()+"") ? "苏州市立医院东区" : "苏州市立医院北区";
		String deptName = dept.getDeptName();
		String expertName = "";
		String date = DateUtil.formatDate(new Date());
		String half = getHalf(); 
		String json = schedualTime(hospitalName, deptName, expertName, date, half);
		Tools.encryptPrint(out, json);
	} else {
		List<Schedule> shcedules = QBuilder.db("basedb").select().from("Schedule").where(new Where("hospital =", hospital).and("status = ", STATUS_ENABLE).and("id=", id)).query().getResultObj();
		if (shcedules.size() == 0) {
			msg = new Message(30041, "获取号源失败");
			Tools.encryptPrint(out, msg);
			return;
		}
		Schedule schedule = shcedules.get(0);
		String hospitalName = "1".equals(schedule.getBranch()+"") ? "苏州市立医院本部" : "2".equals(schedule.getBranch()+"") ? "苏州市立医院东区" : "苏州市立医院北区";
		String deptName = schedule.getDeptName();
		String expertName = schedule.getDoctorName();
		String date = schedule.getDate();
		String half = schedule.getHalf() + "";
		String json = schedualTime(hospitalName, deptName, expertName, date, half);
		Tools.encryptPrint(out, json);
	}
%>
